{% extends 'base.html' %}

{% block title %}高级搜索{% endblock %}

{% block content %}
<div class="max-w-4xl mx-auto">
    <div class="bg-white rounded-lg shadow-sm p-6">
        <h2 class="text-2xl font-bold mb-6">高级搜索</h2>
        <form action="{{ url_for('blog.search') }}" method="get" class="space-y-6">
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-2">
                    关键词
                </label>
                <input type="text" name="q" value="{{ request.args.get('q', '') }}"
                       class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
            </div>
            
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-2">
                    标签
                </label>
                <div class="space-y-2">
                    {% for tag in tags %}
                    <label class="inline-flex items-center mr-4">
                        <input type="checkbox" name="tags" value="{{ tag.name }}"
                               {% if tag.name in selected_tags %}checked{% endif %}
                               class="rounded border-gray-300 text-blue-600 focus:ring-blue-500">
                        <span class="ml-2">{{ tag.name }}</span>
                    </label>
                    {% endfor %}
                </div>
            </div>
            
            <div class="grid grid-cols-2 gap-4">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">
                        开始日期
                    </label>
                    <input type="date" name="start_date" value="{{ request.args.get('start_date', '') }}"
                           class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
                </div>
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">
                        结束日期
                    </label>
                    <input type="date" name="end_date" value="{{ request.args.get('end_date', '') }}"
                           class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
                </div>
            </div>
            
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-2">
                    排序方式
                </label>
                <select name="sort" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
                    <option value="recent" {% if sort == 'recent' %}selected{% endif %}>最新发布</option>
                    <option value="views" {% if sort == 'views' %}selected{% endif %}>最多浏览</option>
                    <option value="comments" {% if sort == 'comments' %}selected{% endif %}>最多评论</option>
                </select>
            </div>
            
            <div class="flex justify-end">
                <button type="submit"
                        class="px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
                    搜索
                </button>
            </div>
        </form>
    </div>
</div>
{% endblock %} 